﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

using BlueCMS.Core.Pages;

namespace BlueCMS.Core.Entities
{
    public class TemplateFragment
    {
        public Guid template_id { get; set; }
        public int displayorder { get; set; }
        public Guid website_id { get; set; }
        public string type_cd { get; set; }
        public string literal { get; set; }
        public string region_nm { get; set; }
        public bool ismasterregion { get; set; }

        public Template Template { get; internal set; }

        public void InstantiateIn(Control control, Webpage page)
        {
            switch (type_cd)
            {
                case "LITERAL":
                    {
                        control.Controls.Add(new LiteralControl(literal));
                    }
                    break;
                case "CONTENT_REGION":
                    {
                        ContentRegion region = new ContentRegion(region_nm, ismasterregion, page);
                        control.Controls.Add(region);
                    }
                    break;
            }
        }
    }
}
